{include file="public_iframe:head"}
<script type="text/javascript" charset="utf-8" src="__STATIC__/editor/ueditor.config.js"></script>
<script type="text/javascript" charset="utf-8" src="__STATIC__/editor/ueditor.all.min.js"> </script>
<script type="text/javascript" charset="utf-8" src="__STATIC__/editor/lang/zh-cn/zh-cn.js"></script>
<body class="gray-bg">
<div class="wrapper wrapper-content animated fadeInRight">
    <div class="ibox float-e-margins">
        <div class="ibox-title">
            <h5>行业分类编辑</h5>
            <div class="ibox-tools" style="margin-top: -9px;">
                <a href="javascript:history.go(-1);" class="btn btn-primary"><i class="fa fa-arrow-left"></i> 返回</a>
            </div>
        </div>
        <div class="ibox-content">
            <form action="{:url('Industry/add_lists')}" method="post" enctype="multipart/form-data" id="brandForm" class="form-horizontal">
                <input type="hidden" name="id" value="{$industry.id?$industry.id:'';}">
                <div class="form-group">
                    <label class="col-sm-2 control-label">父分类</label>
                    <div class="col-sm-6">
                        <select class="form-control m-b" name="parent_id" onchange="category(this)">
                            <option value="0">请选择父分类</option>
                            {volist name="industry_category" id="vo"}
                                <option value="{$vo.id}" {if condition="$parent_category_cid.parent_id eq $vo.id && $parent_category_cid.parent_id neq '0'"}selected = "selected"{/if}>{$vo.name}</option>
                            {/volist}
                        </select>
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-sm-2 control-label">子分类(不选则作为父分类)</label>
                    <div class="col-sm-6">
                        <select class="form-control m-b cid" name="cid">
                            {volist name="industry_category_nav" id="vo"}
                                <option value="{$vo.id}" {if condition="$industry.cid eq $vo.id"}selected = "selected"{/if}>{$vo.name}</option>
                            {/volist}
                        </select>
                    </div>
                </div>
                <div class="hr-line-dashed"></div>
                <div class="form-group">
                    <label class="col-sm-2 control-label">行业分类名称</label>
                    <div class="col-sm-6">
                        <input type="text" name="name" class="form-control" value="{$industry.name}">
                    </div>
                </div>
                <div class="hr-line-dashed"></div>
                <div class="form-group">
                    <div class="col-sm-4 col-sm-offset-2">
                        <!--<button class="btn btn-primary" type="submit">提交</button>-->
                        <!--href="JavaScript:void(0);" onclick="roleSubmit();"-->
                        <button class="btn btn-primary" onclick="Submit()" id="submit">提交</button>
                    </div>
                </div>
            </form>
        </div>
    </div>
</div>
</body>
<script type="text/javascript">
    function category(obj){
        var val = $(obj).val();
        if(val != 0){
            var formData = new FormData();

            formData.append('parent_id',val);

            $.ajax({
                url:"{:url('Industry/select_catgory_result')}",
                type:'POST',
                data:formData,
                async:false,
                processData:false,
                contentType:false,
                success:function(result) {
                     if(result.msg.length != 0){
                        var html = '';
                        for (var i = 0; i < result.msg.length; i++) {
                            html +='<option value="'+result.msg[i].id+'">'+result.msg[i].name+'</option>';
                        }

                        $('.cid').append(html);
                     }

                }
            });
        }
    }

</script>
</html>